<template>
	<view>
		<view class="NabBox">
			<view :class="num==index?'bgfff':''" v-for="(item,index) in NavList" :key="index" @click="Nav(index)">{{item}}</view>
		</view>
		
		<view class="MainBox">
			<view class="Title" v-if="num==0">请填写退货发货信息</view>
			<view class="Title" v-if="num==1">请填写换货发货信息</view>
			<view class="company">
				物流公司：
					<picker  @change="bindPickerChange" :range="array" class="Infoinput">	
						<label class="">{{array[index]}}</label>
					</picker>
			</view>
			<view class="Numbers">
				物流订单号：<input type="text" maxlength="36" v-model="invoice_no" value="" />
			</view>
			<view class="Tips">
				发货五天后，当商家选择未收到则要进行延迟时间操作，如果超过
				七天不处理按期货处理，直接由管理员确认退款
			</view>
			<view class="confirm" @click="confirm()">
				确认
			</view>
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				NavList:["退货申请","换货申请"],
				num:0,
				index:0,
				array:[],
				arrayNum:[],
				area_code:[],
				express_list:"",//快递公司列表
				return_id:"",//换货id
				express_id:"",//快递公司id
				invoice_no:""//物流单号
			}
		},
		onLoad(e) {
			if(e.express_list){
				this.express_list=JSON.parse(e.express_list)
				this.express_list.map(item=>{
					this.array.push(item.e_name)
				})
			}
			if(e.return_id){
				this.return_id=e.return_id;
			}
			if(e.Navindex){
				this.num=e.Navindex
			}
		},
		methods: {
			confirm(){
				if(this.num==0){
					this.$util.request({//退货物流单号
						url:'/mobile/index.php?act=member_return&op=ship',
						method:'POST',
						data:{
							return_id:this.return_id,
							express_id:this.express_id,
							invoice_no:this.invoice_no
						}
					}).then(res=>{
						if(res.error_code==0){
							uni.showToast({
								title:"已提交退货物流单号",
								success() {
									setTimeout(()=>{
										uni.navigateTo({
											url:"tuihuo"
										})
									},1500)
									
								}
							})
						}else{
							uni.showToast({
								title:res.message,
								icon:"none"
							})
						}
					})
				}else if(this.num==1){
					this.$util.request({//换货物流单号
						url:'/mobile/index.php?act=member_exchange&op=ship',
						method:'POST',
						data:{
							return_id:this.return_id,
							express_id:this.express_id,
							invoice_no:this.invoice_no
						}
					}).then(res=>{
						if(res.error_code==0){
							uni.showToast({
								title:"已提交换货物流单号",
								success() {
									setTimeout(()=>{
										uni.navigateTo({
											url:"xuniDM"
										})
									},1500)
								
								}
							})
						}else{
							uni.showToast({
								title:res.message,
								icon:"none"
							})
						}
					})
				}

			},
			
			
			
			
			bindPickerChange: function(e) {	//改变的事件名
				console.log('picker发送选择改变，携带值为', e.target.value)   //用于输出改变索引值
				this.index = e.target.value			//将数组改变索引赋给定义的index变量
				// this.jg=this.array[this.index]		//将array【改变索引】的值赋给定义的jg变量
				this.express_id=this.express_list[e.target.value].id
			},
			Nav(index){
				this.num=index;
			}
		}
	}
</script>

<style>
	page{
		background-color: #FFFFFF;
	}
	input,.Infoinput{
		background-color: #EEEEEE;
		margin: 10rpx 0;
		height: 60rpx;
		line-height: 60rpx;
		padding-left: 20rpx;
	}
	.NabBox{
		border: 1rpx solid #b0b0b0b0;
		display: flex;
		background-color: #F8F8F8;
	}
	.NabBox>view{
		line-height: 80rpx;
		width: 50%;
		text-align: center;
	}
	.bgfff{
		background-color: #FFFFFF;
	}
	.MainBox{
		padding: 30rpx;
	}
	.Title{
		font-size: 36rpx;
	}
	.MainBox .company,.MainBox .Numbers{
		font-size: 30rpx;
		margin: 20rpx 0;
		color: #333333;
		/* font-weight: bold; */
	}
	.Tips{
		color: #999999;
	}
	.confirm{
		font-size: 34rpx;
		width: 90%;
		line-height: 70rpx;
		margin: 100rpx  auto;
		background-color: red;
		color: #FFFFFF;
		font-weight: bold;
		text-align: center;
	}
</style>
